package jihe;

import java.util.ArrayList;
import java.util.LinkedHashSet;
import java.util.List;

//集合去重
public class jihe {
    public static void main(String[] args) {
        ArrayList<String> list = new ArrayList<>();
        list.add("张三");
        list.add("张三");
        list.add("李四");
        list.add("张三");
        list.add("五五");
        list.add("张三");
        list.add("张三");

        quChong(list);
        System.out.println(list);
    }

    private static void quChong(ArrayList<String> list) {
        LinkedHashSet<String> linkedHashSet = new LinkedHashSet<>();
        linkedHashSet.addAll(list);
        list.clear();
        list.addAll(linkedHashSet);
    }
}
